﻿@using System.Web.Optimization
@using BlogEngine.Core
<!DOCTYPE html>
@{
    if (!Security.IsAuthorizedTo(Rights.EditOwnPosts))
    {
        Security.RedirectForUnauthorizedRequest();
    }
    string loginUrl = Href(Utils.RelativeWebRoot + "Account/login.aspx");
    var userRights = string.Join("','", Security.CurrentUserRights().Select(r => r.Flag).ToArray());
    var id = Request["id"];
    var returnUrl = Request["return"];
    if (string.IsNullOrEmpty(returnUrl)) { returnUrl = Utils.RelativeWebRoot + "admin/#/content"; }
    var imgHandler = "image.axd?picture=";
    if (string.IsNullOrEmpty(Blog.CurrentInstance.StorageContainerName))
    {
        imgHandler = Blog.CurrentInstance.RelativeWebRoot + imgHandler;
    }
    else
    {
        imgHandler = Blog.CurrentInstance.RelativeWebRoot + Blog.CurrentInstance.StorageContainerName + "/" + imgHandler;
    }
}
<html data-ng-app="blogAdmin">
<head>
    <meta charset="utf-8" />
    <link href='http://fonts.googleapis.com/css?family=Roboto:300,400,500' rel='stylesheet' type='text/css'>
    @Styles.Render("~/Content/admincss")
    <link href="~/admin/themes/standard/css/styles.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        var UserVars = { Name: '@Security.CurrentUser.Identity.Name', IsAdmin: '@Security.IsAdministrator', Rights: ['@Html.Raw(userRights)'] };
        var editVars = { id: '@id', storageLocation: '@BlogConfig.StorageLocation' };
    </script>
    <script type="text/javascript" src="admin.res.axd"></script>
</head>
<body class=" @Resources.labels.LangDirection-dir" ng-controller="FileManagerController">
    <div class="filemanager">
        @Scripts.Render("~/scripts/wysiwyg")
        <form id="form" action="" class="file-form">
            <div id="modal-form" class="modal fade">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true" ng-click="focusInput=false"><i class="fa fa-times"></i></button>
                            <h4 class="modal-title">{{lbl.addFolder}}</h4>
                        </div>
                        <div class="modal-body">
                            <div class="form-group">
                                <label for="txtFolder">{{lbl.title}}</label>
                                <input type="text" class="form-control" id="txtFolder" name="txtFolder" data-ng-model="dirName" focus-me="focusInput" />
                            </div>
                            <div class="modal-buttons">
                                <button type="button" ng-click="createFolder()" class="btn btn-success btn-hasicon"><i class="fa fa-check"></i>{{lbl.save}}</button>
                                <button type="button" class="btn btn-default" data-dismiss="modal" ng-click="focusInput=false">{{lbl.cancel}}</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="main-header clearfix">
                <input type="file" id="file" name="file" class="pull-left input-file-hidden" tabindex="-1" onchange="angular.element(this).scope().uploadFile(this.files)" />
                <button type="button" class="pull-left btn btn-success btn-sm btn-hasicon btn-input-file prev"><i class="fa fa-plus"></i>{{lbl.upload}}</button>
                <button type="button" class="pull-left btn btn-sm btn-success btn-hasicon" ng-click="addFolder()"><i class="fa fa-folder"></i>{{lbl.theNew}} Folder</button>
                <button type="button" class="pull-left btn btn-sm btn-danger btn-icon" ng-click="processChecked('delete')" ng-disabled="itemsChecked() === false" angular-tooltip tooltip="lbl.doDelete"><i class="fa fa-trash"></i></button>
                <span id="file-spinner" style="padding-left: 10px; position: relative; top: 5px"><i class="fa fa-spinner fa-spin"></i></span>
                <input type="text" data-ng-model="query" data-ng-change="search()" class="input-sm form-control search-form pull-right" placeholder="{{lbl.search}}..." />
            </div>
            <div class="filemanager-content">
                <div class="filemanager-path">{{currentPath}}</div>
                <div class="filemanager-list clearfix">
                    <div class="item-file" ng-repeat="item in pagedItems[currentPage] | orderBy:sortingOrder">
                        <div class="item-file-image">
                            <a ng-if="item.FileType === 0 && item.Name != '...'" title="{{item.Name}}" href="" ng-click="load(item.FullPath)">
                                <i class="fa fa-folder"></i>
                            </a>
                            <a ng-if="item.FileType === 0 && item.Name === '...'" title="{{item.Name}}" href="" ng-click="load(item.FullPath)">
                                <i class="fa fa-arrow-left"></i>
                            </a>
                            <a ng-if="item.FileType === 1" title="{{item.Name}}" href="" ng-click="insertFile(item)">
                                <i ng-class="item.ImgPlaceholder"></i>
                            </a>
                            <a ng-if="item.FileType === 2" title="{{item.Name}}" href="" ng-click="insertFile(item)">
                                <img ng-src="@imgHandler{{item.FullPath}}" />
                            </a>
                        </div>
                        <div class="item-file-name">
                            <label><input ng-if="item.Name != '...'" type="checkbox" data-ng-model="item.IsChecked" /> <span class="text-ellipsis">{{item.Name.substring(0,12)}}</span></label>
                        </div>
                    </div>
                </div>
            </div>
            <div ng-if="items.length > itemsPerPage" class="text-right pagination-wrapper" style="margin-top: 10px">
                <ul class="pagination pagination-sm">
                    <li data-ng-class="{disabled: currentPage == 0}"><a data-ng-click="prevPage()">« {{lbl.prev}}</a></li>
                    <li data-ng-repeat="n in range(pagedItems.length)" data-ng-class="{active: n == currentPage}" data-ng-click="setPage()"><a data-ng-bind="n + 1">1</a></li>
                    <li data-ng-class="{disabled: currentPage == pagedItems.length - 1}"><a data-ng-click="nextPage()">{{lbl.next}} »</a></li>
                </ul>
            </div>
        </form>
    </div>
    <script>
        // input file
        $(".btn-input-file.prev").click(function () {
            $(this).prev('input').click();
        });
        $(".btn-input-file.next").click(function () {
            $(this).next('input').click();
        });
    </script>
</body>
</html>